import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:image_picker/image_picker.dart';
//获取图片以及拍照常用的第三方插件imger——picker
class AuthenticationId extends StatefulWidget {
  @override
  _AuthenticationIdState createState() => _AuthenticationIdState();
}
class _AuthenticationIdState extends State<AuthenticationId>{
  var imgPath;
  /*拍照*/
  takePhoto() async {
    var image = await ImagePicker.pickImage(source: ImageSource.camera);
    setState(() {
      imgPath = image;
    });
  }
  /*相册*/
  openGallery() async {
    var image = await ImagePicker.pickImage(source: ImageSource.gallery);
    setState(() {
      imgPath = image;
    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("认证"),
          elevation: 0.0,
        ),
        body: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Container(
                child: imgPath == null ? Text('请选择拍照'):Image.file(imgPath),
              ),
              RaisedButton(
                onPressed: takePhoto,
                child: Text("拍照"),
              ),
              RaisedButton(
                onPressed: openGallery,
                child: Text("选择照片"),
              ),
              Container(
                child: Text("eqewqeq",style: TextStyle(fontSize: 5,color: Colors.red,fontWeight: FontWeight.bold)),),
                //padding/marging 那边距离 外边距 left top right设置EdgeInsets去设置这4个边距左/上/右/下设置4个距离
                //在这里进行文字的加载展示去显示效果并表明数据
                //EdgeInsets.all(value)/EdgeInsets.only(left:)/Edgeinsets.fromTRB/fromTRB(left top right bottom)
                // width/height padding margin/Edgeinsts/alignment来决定Container内部的子组件也会pailie alignment。topleft/topCenter/center
              Container(
                child: Image.asset("eqeqeqeqewqeq",width: 250,height: 250,fit:BoxFit.fitWidth,repeat: ImageRepeat.repeat,color:Color(0XFFF7528)),
                width: 200,
                height: 200,
              ),
            ],
          ),
        ));
  }
}
